package cn.wolfcode.trip.base.service.impl;

import cn.wolfcode.trip.base.domain.Respond;
import cn.wolfcode.trip.base.mapper.RespondMapper;
import cn.wolfcode.trip.base.query.RespondQueryObject;
import cn.wolfcode.trip.base.service.IRespondService;
import cn.wolfcode.trip.base.util.UserContext;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.List;

@Service
public class RespondServiceImpl implements IRespondService {

    @Autowired
    private RespondMapper respondMapper;

    /**
     * 添加解答信息
     * @param respond
     */
    @Override
    public void insertRespond(Respond respond) {
        respond.setOther(UserContext.getCurrentUser());
        respondMapper.insert(respond);
    }

    @Override
    public PageInfo selectRespondById(RespondQueryObject qo) {
        PageHelper.startPage(qo.getCurrentPage(),qo.getPageSize());
        List <Respond> list=respondMapper.selectRespondById(qo);
        return new PageInfo(list);
    }
}
